package com.taoye.thread;

public class Demo09 {
	public static void main(String[] args) throws InterruptedException {
		Demo09Thread t = new Demo09Thread();
		t.start();
		Thread.sleep(50);
		t.interrupt();
		System.out.println("t线程的interrupt状态："+t.isInterrupted());
	}
}

class Demo09Thread extends Thread {

	@Override
	public void run() {
		for (int i = 0; i < Integer.MAX_VALUE; i++) {
			if(this.isInterrupted()) { //在这里使用isInterrupted方法判断线程是否被终止
				break;
			}
			System.out.println("当前i=" + i);
		}
		System.out.println("线程执行结束了");
	}
}